#ifndef TREGIST_H
#define TREGIST_H

#ifndef STRICT
#define STRICT
#endif
#include "windows.h"

#define MAX_KEYARRAY	30

class TRegistry {
protected:
	HKEY	topKey;
	int		openCnt;
	HKEY	hKey[MAX_KEYARRAY];

public:
	TRegistry(LPCSTR company, LPSTR appName=NULL);
	TRegistry(HKEY top_key);
	~TRegistry();

	void	ChangeTopKey(HKEY topKey);
	BOOL	ChangeApp(LPCSTR company, LPSTR appName=NULL);
	BOOL	GetInt(LPCSTR key, int *val);
	BOOL	SetInt(LPCSTR key, int val);
	BOOL	GetLong(LPCSTR key, long *val);
	BOOL	SetLong(LPCSTR key, long val);
	BOOL	GetStr(LPCSTR key, LPSTR str, int size);
	BOOL	SetStr(LPCSTR key, LPCSTR str);
	BOOL	GetByte(LPCSTR key, BYTE *data, int *size);
	BOOL	SetByte(LPCSTR key, const BYTE *data, int size);
	BOOL	OpenKey(LPCSTR subKey, BOOL createFlg=FALSE);
	BOOL	CreateKey(LPCSTR subKey) { return OpenKey(subKey, TRUE); }
	BOOL	CloseKey(void);
	BOOL	DeleteKey(LPCSTR str);
	BOOL	DeleteValue(LPCSTR str);
	BOOL	EnumKey(DWORD cnt, LPSTR buf, int size);
	BOOL	EnumValue(DWORD cnt, LPSTR buf, int size, DWORD *type=NULL);
	BOOL	DeleteChildTree(LPSTR subkey=NULL);
};

#endif